<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex classification_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center'>
          <view class='flex align-center flex-sub classification_fd0_0_c0' @tap="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/sy/search/search`">
            <image class='classification_fd0_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"195.png"'></image>
            <text class='classification_fd0_0_c0_c1'>{{$t('搜索你想要的商品')}}</text>
          </view>
          <view class='flex flex-wrap align-center classification_fd0_0_c1' v-if=" appSystemIdentification=='Wechat'">
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <benben-goods-classify class='flex  classification_flex_classify_1' :top='88' threeLevel='false'
        :handle-id.sync='click_aid' :lists='dataList' @refresh="queryListFunc()" @handle-item="jumpFunc(click_aid)">
      </benben-goods-classify>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "dataList": [],
        "click_aid": "",
        "keyword": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      /**
       * @returns
       * Android       安卓
       * IOS       苹果
       * Web       H5 或 pc
       * Wechat       微信小程序
       * Alipay       支付宝小程序
       * Baidu       百度小程序
       * ByteBounce       抖音小程序
       * 360       360小程序
       * FastApp       快应用
       */
      appSystemIdentification() {
        return this.$store.state.appSystemIdentification
      }
    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

      console.log('click_aid', this.click_aid)
      this.queryListFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //商品管理-获取推荐商品分类
      async queryListFunc() {
        //请求方法
        //数据验证

        let datadataList = await this.$api.get(global.apiUrls.getHomeCommodTypes, {
          isShowHome: '0',
          seetNum: '2'
        });

        if (datadataList.data.code != 0) {
          if (datadataList.data.code == 6) {
            this.$store.commit('logout')
            this.$urouter.switchTab(`/pages/tabBar/myhb/myhb`);
          } else {
            this.$message.info(datadataList.data.msg);
          }
          return
        }

        let infodataList = datadataList.data;
        this.dataList = infodataList.data
        if (uni.getStorageSync('cateId')) {
          this.click_aid = uni.getStorageSync('cateId')
        } else {
          this.click_aid = this.dataList[0].id
        }

        console.log('click_aid', this.click_aid)
      },
      //跳转
      jumpFunc(id) {
        this.$urouter.navigateTo(`/pages/fl/commodityList/commodityList?keyword=${this.keyword}&cid=${this.click_aid}`);
      },
      //搜索
      keywordFunc(id) {
        this.$urouter.navigateTo(`/pages/fl/commodityList/commodityList?keyword=${this.keyword}&cid=${this.click_aid}`);
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .classification_flex_0 {
    border-bottom: 1px solid rgba(238, 238, 238, 1);
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .classification_fd0_0_c1 {
    width: 30%;
  }

  .classification_fd0_0_c0_c1 {
    color: var(--benbenFontColor2);
    font-size: 28rpx;
    margin: 0rpx 0rpx 0rpx 16rpx;
  }

  .classification_fd0_0_c0_c0 {
    width: 24rpx;
    height: 24rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .classification_fd0_0_c0 {
    background: #F9F9F9;
    border-radius: 34rpx 34rpx 34rpx 34rpx;
    margin: 12rpx 32rpx 0rpx 32rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    height: 64rpx;
  }

  ::v-deep .classification_flex_classify_1 {
    --classify-radius: 16rpx;
    --active-tag-color: var(--benbenbgColor7);
  }
</style>
